package com.xinqi.utils.pool;

import org.springframework.stereotype.Component;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author xin麒
 * @date 2023/8/12 15:13
 */
@Component
public class MyJdkPool extends ThreadPoolExecutor {
    public MyJdkPool() {
        super(1
                , 1
                , 0
                , TimeUnit.SECONDS
                , new SynchronousQueue<>(),
                (Runnable r) -> {
            Thread thread = new Thread(r);
            thread.setUncaughtExceptionHandler((Thread thread1, Throwable e) -> {
                System.out.println("线程工厂设置的exceptionHandler" + e.getMessage());
            });
            return thread;

        });
    }
}
